Skip to content

Conversation

@emily-shen
Copy link
Contributor

@emily-shen emily-shen commented Apr 10, 2025

Fixes DEVX-1613

This PR updates c3 to use types generated by wrangler types instead of installing @cloudflare/workers-types.

  • Removes code that installs and updates config for `@cloudflare/workers-types from most frameworks.
  • deletes worker-configuration.d.ts etc. from framework templates, as this now gets generated automatically.

A few frameworks (remix and qwik) pin wrangler 3, which generate runtime types in a different way, so for simplicity we continue installing workers-types for those frameworks. This can be cleaned up in a followup if/when those frameworks upgrade to wrangler v4.

Testing for framework templates has also been updated to always check types based on the template config (ie verifyBuildCfTypes is no longer necessary), and checks the immediate output of c3 instead of the output after re-running typegen.


  • Tests
    • TODO (before merge)
    • Tests included
    • Tests not necessary because:
  • Wrangler / Vite E2E Tests CI Job required? (Use "e2e" label or ask maintainer to run separately)
    • I don't know
    • Required
    • Not required because:
  • Public documentation
  • Wrangler V3 Backport
    • TODO (before merge)
    • Wrangler PR:
    • Not necessary because: not a Wrangler change

@github-project-automation github-project-automation bot moved this to Untriaged in workers-sdk Apr 10, 2025
@workers-devprod workers-devprod added the c3-e2e Run c3 e2e tests on a PR label Apr 10, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Apr 10, 2025

A wrangler prerelease is available for testing. You can install this latest build in your project with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14406763126/npm-package-wrangler-8886

You can reference the automatically updated head of this PR with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/prs/8886/npm-package-wrangler-8886

Or you can use npx with this latest build directly:

npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14406763126/npm-package-wrangler-8886 dev path/to/script.js
Additional artifacts:

cloudflare-workers-bindings-extension:

wget https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14406763126/npm-package-cloudflare-workers-bindings-extension-8886 -O ./cloudflare-workers-bindings-extension.0.0.0-v5e3b99075.vsix && code --install-extension ./cloudflare-workers-bindings-extension.0.0.0-v5e3b99075.vsix

create-cloudflare:

npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14406763126/npm-package-create-cloudflare-8886 --no-auto-update

@cloudflare/kv-asset-handler:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14406763126/npm-package-cloudflare-kv-asset-handler-8886

miniflare:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14406763126/npm-package-miniflare-8886

@cloudflare/pages-shared:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14406763126/npm-package-cloudflare-pages-shared-8886

@cloudflare/unenv-preset:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14406763126/npm-package-cloudflare-unenv-preset-8886

@cloudflare/vite-plugin:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14406763126/npm-package-cloudflare-vite-plugin-8886

@cloudflare/vitest-pool-workers:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14406763126/npm-package-cloudflare-vitest-pool-workers-8886

@cloudflare/workers-editor-shared:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14406763126/npm-package-cloudflare-workers-editor-shared-8886

@cloudflare/workers-shared:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14406763126/npm-package-cloudflare-workers-shared-8886

@cloudflare/workflows-shared:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14406763126/npm-package-cloudflare-workflows-shared-8886

Note that these links will no longer work once the GitHub Actions artifact expires.


[email protected] includes the following runtime dependencies:

Package Constraint Resolved
miniflare workspace:* 4.20250409.0
workerd 1.20250409.0 1.20250409.0
workerd --version 1.20250409.0 2025-04-09

Please ensure constraints are pinned, and miniflare/workerd minor versions match.

@changeset-bot
Copy link

changeset-bot bot commented Apr 10, 2025

🦋 Changeset detected

Latest commit: c5ca33b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
create-cloudflare Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@emily-shen emily-shen force-pushed the emily/c3-types-again branch 3 times, most recently from 7017389 to 9f47f3a Compare April 11, 2025 15:35
@emily-shen emily-shen marked this pull request as ready for review April 11, 2025 15:35
@emily-shen emily-shen requested a review from a team April 11, 2025 15:35
@emily-shen emily-shen requested a review from a team as a code owner April 11, 2025 15:35
@emily-shen emily-shen force-pushed the emily/c3-types-again branch from 57357b0 to dc30b81 Compare April 14, 2025 06:33
@github-actions
Copy link
Contributor

These changes have been automatically backported to Wrangler v3 🎉 You can view the automatically updated PR at v3-maintenance...v3-maintenance-8886. Please check that PR for correctness, and make sure it's merged after this one. Thank you for helping us keep Wrangler v3 supported!

@github-actions
Copy link
Contributor

github-actions bot commented Apr 14, 2025

A Wrangler prerelease is available for testing. You can install this latest build in your project with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14903120110/npm-package-wrangler-8886
Prereleases for other packages:

cloudflare-workers-bindings-extension:

wget https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14903120110/npm-package-cloudflare-workers-bindings-extension-8886 -O ./cloudflare-workers-bindings-extension.0.0.0-v9c97da27b.vsix && code --install-extension ./cloudflare-workers-bindings-extension.0.0.0-v9c97da27b.vsix

create-cloudflare:

npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14903120110/npm-package-create-cloudflare-8886 --no-auto-update

@cloudflare/kv-asset-handler:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14903120110/npm-package-cloudflare-kv-asset-handler-8886

miniflare:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14903120110/npm-package-miniflare-8886

@cloudflare/pages-shared:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14903120110/npm-package-cloudflare-pages-shared-8886

@cloudflare/unenv-preset:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14903120110/npm-package-cloudflare-unenv-preset-8886

@cloudflare/vite-plugin:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14903120110/npm-package-cloudflare-vite-plugin-8886

@cloudflare/vitest-pool-workers:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14903120110/npm-package-cloudflare-vitest-pool-workers-8886

@cloudflare/workers-editor-shared:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14903120110/npm-package-cloudflare-workers-editor-shared-8886

@cloudflare/workers-shared:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14903120110/npm-package-cloudflare-workers-shared-8886

@cloudflare/workflows-shared:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14903120110/npm-package-cloudflare-workflows-shared-8886

Note that these links will no longer work once the GitHub Actions artifact expires.

},
},
},
compatibilityFlags: ["nodejs_compat"],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to add this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the flag was already there (in the wrangler configs), just not in the c3 templateConfig here. Its not great that they can be out of sync like this, but this sort of thing happens all over c3 and is probably beyond the scope of this PR to fix. (I'll make sure I don't add to the problem though...)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked at it when working on #9147

This flag is only used by pages (9147 updates the description).

So I think it can be removed from here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we usecompatibilityFlags in this PR here to make sure @types/node is installed. i can update the comment to reflect this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually to get around the issue of this getting out of sync, and to support remote templates, that bit should probably read the wrangler config instead - i'll update that.

Copy link
Contributor

@vicb vicb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a few comments.

Is there any reason why i.e. Next is not in this PR?

@emily-shen
Copy link
Contributor Author

emily-shen commented Apr 14, 2025

Added a few comments.

Is there any reason why i.e. Next is not in this PR?

next + workers was in the pr, but i seem to have left out next on pages by accident - ac7026a (well everything is 'included' automatically, but there was a redundant file to delete)

@emily-shen emily-shen force-pushed the emily/c3-types-again branch 2 times, most recently from 2c9506f to 4d5aab7 Compare April 15, 2025 22:32
@emily-shen emily-shen added the e2e Run wrangler + vite-plugin e2e tests on a PR label Apr 16, 2025
@vicb
Copy link
Contributor

vicb commented May 5, 2025

@emily-shen could you please rebase the PR and answer the comments?

Copy link
Contributor

@vicb vicb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added inline comments.

The PR contains quite a lot of changes.
I think it would help reviewing if the description of the PR lists what is changed in the PR - something to keep in mind for future PRs.

Thanks!

@emily-shen
Copy link
Contributor Author

Added inline comments.

The PR contains quite a lot of changes. I think it would help reviewing if the description of the PR lists what is changed in the PR - something to keep in mind for future PRs.

Thanks!

Ah great feedback, i've updated it now for posterity (and good habits!)

expect(hasEnvInterfacePre).toBe(true);

// Run the `cf-typegen` script to generate types for bindings in fixture
const buildTypesProc = spawnWithLogging(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think its useful here to test wrangler types works, so instead this now tests the immediate output of c3 is as expected.

@emily-shen emily-shen force-pushed the emily/c3-types-again branch from 7008d4d to c5ca33b Compare May 8, 2025 09:21
Copy link
Contributor

@vicb vicb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM,
Thanks Emily!

@github-project-automation github-project-automation bot moved this from Untriaged to Approved in workers-sdk May 8, 2025
@emily-shen emily-shen merged commit e1df3d8 into main May 8, 2025
18 checks passed
@emily-shen emily-shen deleted the emily/c3-types-again branch May 8, 2025 10:17
@github-project-automation github-project-automation bot moved this from Approved to Done in workers-sdk May 8, 2025
@workers-devprod workers-devprod mentioned this pull request May 8, 2025
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deleting this file has broken the CI in Version Packages @emily-shen

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Repro:

npx create-cloudflare@beta --platform=pages --framework=next -- --yes

It is because we need to also remove the bit in c3.ts that is trying to copy it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We missed it in the PR CI jobs because next-on-pages was excluded from pnpm runs.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix in #9182

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c3-e2e Run c3 e2e tests on a PR e2e Run wrangler + vite-plugin e2e tests on a PR

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants